package view;

import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.util.ArrayList;
import javax.swing.JLabel;
import model.Candidato;
import model.Cargo;
import model.Eleitor;
import model.Voto;
import util.UrnaUtil;
import util.ValidaCaracteres;
import util.ViewUtil;

public class Principal extends javax.swing.JFrame {

  /*
   Revisar todas essas variáveis  
   */
  private int lengthNumeroCargo;
  private int campoAtivo;
  private int qtdeCargos;
  private int cargoAtual;
  private ArrayList<Cargo> listaCargos = Cargo.getAllCargos();
  private CardLayout card;
  private boolean votoBranco;

  //  

  public Principal(String perfil) {

    initComponents();
    setExtendedState(MAXIMIZED_BOTH);
    jTextFieldNomeEleitor.setDocument(new ValidaCaracteres(";"));
    switch (perfil) {
      case "Eleitor":
        ViewUtil.trocaPanels(jPanelFrame , jPanelInfoEleitor);
        //ViewUtil.trocaPanels(jPanelFrame, pnlVotacao);
        qtdeCargos = listaCargos.size();
        cargoAtual = 0;
        InicializeTelaVotacao(listaCargos.get(cargoAtual));
        showViewCandidato();
        break;
      case "Administrador":               
        ViewUtil.trocaPanels(jPanelFrame, jPanelAdministrador);
        break;
    }
  }

  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    pnlVotacao = new javax.swing.JPanel();
    pnlCenter = new javax.swing.JPanel();
    pnlTeclado = new javax.swing.JPanel();
    pnlNumeros = new javax.swing.JPanel();
    btnNum1 = new javax.swing.JButton();
    btnNum2 = new javax.swing.JButton();
    btnNum3 = new javax.swing.JButton();
    btnNum4 = new javax.swing.JButton();
    btnNum5 = new javax.swing.JButton();
    btnNum6 = new javax.swing.JButton();
    btnNum7 = new javax.swing.JButton();
    btnNum8 = new javax.swing.JButton();
    btnNum9 = new javax.swing.JButton();
    btnNum0 = new javax.swing.JButton();
    pnlButoesAcao = new javax.swing.JPanel();
    btnBranco = new javax.swing.JButton();
    btnCorrige = new javax.swing.JButton();
    btnConfirma = new javax.swing.JButton();
    pnlDetalheVotacao = new javax.swing.JPanel();
    pnlDadosCadidato = new javax.swing.JPanel();
    pnlCandidatoTop = new javax.swing.JPanel();
    pnlFotoCandidato = new javax.swing.JPanel();
    lblFotoCandidato = new javax.swing.JLabel();
    lblTextoCandidato = new javax.swing.JLabel();
    pnlCargo = new javax.swing.JPanel();
    lblSeuVoto = new javax.swing.JLabel();
    lblCargo = new javax.swing.JLabel();
    lblNumero = new javax.swing.JLabel();
    pnlInputNumeros = new javax.swing.JPanel();
    lblNum1 = new javax.swing.JLabel();
    lblNum2 = new javax.swing.JLabel();
    lblNum3 = new javax.swing.JLabel();
    lblNum4 = new javax.swing.JLabel();
    lblNum5 = new javax.swing.JLabel();
    pnlCandidatoCenter = new javax.swing.JPanel();
    pnlNomeCandidato = new javax.swing.JPanel();
    lblNomeCandidato = new javax.swing.JLabel();
    lblPartido = new javax.swing.JLabel();
    lblVicePriSuplenteNome = new javax.swing.JLabel();
    lblSegSuplenteNome = new javax.swing.JLabel();
    jPanel2 = new javax.swing.JPanel();
    pnlFotoSegSuplente = new javax.swing.JPanel();
    lblFotoSegSuplente = new javax.swing.JLabel();
    lblTextoFotoSegSuplente = new javax.swing.JLabel();
    pnlFotoVicePriSuplente = new javax.swing.JPanel();
    lblFotoVicePriSuplente = new javax.swing.JLabel();
    lblTextoFotoVicePriSuplente = new javax.swing.JLabel();
    pnlCandidatoButton = new javax.swing.JPanel();
    jSeparator1 = new javax.swing.JSeparator();
    pnlHelpTop = new javax.swing.JPanel();
    lblAperte = new javax.swing.JLabel();
    pnlHelpCenter = new javax.swing.JPanel();
    lblTextoBotaoVerde = new javax.swing.JLabel();
    pnlHelpButton = new javax.swing.JPanel();
    lblTextoBotaoLaranja = new javax.swing.JLabel();
    pnlFimVotacao = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jPanel5 = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    pnlTop = new javax.swing.JPanel();
    pnlBotton = new javax.swing.JPanel();
    pnlRigth = new javax.swing.JPanel();
    pnlLeft = new javax.swing.JPanel();
    jPanelInfoEleitor = new javax.swing.JPanel();
    jPanel1 = new javax.swing.JPanel();
    jLabelTitulo = new javax.swing.JLabel();
    jPanel3 = new javax.swing.JPanel();
    jPanel9 = new javax.swing.JPanel();
    jLabelNomeEleitor = new javax.swing.JLabel();
    jTextFieldNomeEleitor = new javax.swing.JTextField();
    jLabelCpfEleitor = new javax.swing.JLabel();
    jFormattedTextFieldCpf = new javax.swing.JFormattedTextField();
    jLabelTituloEleitor = new javax.swing.JLabel();
    jFormattedTextFieldTitulo = new javax.swing.JFormattedTextField();
    jLabelRgEleitor = new javax.swing.JLabel();
    jFormattedTextFieldRg = new javax.swing.JFormattedTextField();
    jPanel10 = new javax.swing.JPanel();
    jPanel6 = new javax.swing.JPanel();
    jPanel7 = new javax.swing.JPanel();
    jButtonPerfil = new javax.swing.JButton();
    jButtonVotar = new javax.swing.JButton();
    jPanel8 = new javax.swing.JPanel();
    jLabelCamposEleitor = new javax.swing.JLabel();
    jPanelAdministrador = new javax.swing.JPanel();
    jPanel11 = new javax.swing.JPanel();
    jButtonCandidato = new javax.swing.JButton();
    jButtonCargo = new javax.swing.JButton();
    jButtonApuracao = new javax.swing.JButton();
    jPanel12 = new javax.swing.JPanel();
    jPanel13 = new javax.swing.JPanel();
    jButtonPerfil1 = new javax.swing.JButton();
    jPanel14 = new javax.swing.JPanel();
    jPanel15 = new javax.swing.JPanel();
    jPanelFrame = new javax.swing.JPanel();

    pnlVotacao.setLayout(new java.awt.BorderLayout());

    pnlCenter.setBackground(new java.awt.Color(0, 51, 51));
    pnlCenter.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
    pnlCenter.setMinimumSize(new java.awt.Dimension(1024, 500));
    pnlCenter.setPreferredSize(new java.awt.Dimension(1024, 500));
    pnlCenter.setLayout(new java.awt.BorderLayout(40, 0));

    pnlTeclado.setBackground(new java.awt.Color(0, 0, 0));
    pnlTeclado.setMinimumSize(new java.awt.Dimension(400, 600));
    pnlTeclado.setPreferredSize(new java.awt.Dimension(400, 600));
    pnlTeclado.setLayout(new java.awt.BorderLayout());

    pnlNumeros.setBackground(new java.awt.Color(0, 0, 0));
    pnlNumeros.setMinimumSize(new java.awt.Dimension(400, 400));
    pnlNumeros.setPreferredSize(new java.awt.Dimension(400, 400));
    java.awt.GridBagLayout pnlNumerosLayout = new java.awt.GridBagLayout();
    pnlNumerosLayout.columnWidths = new int[] {0, 6, 0, 6, 0};
    pnlNumerosLayout.rowHeights = new int[] {0, 7, 0, 7, 0, 7, 0};
    pnlNumerosLayout.columnWeights = new double[] {0.0};
    pnlNumerosLayout.rowWeights = new double[] {0.0};
    pnlNumeros.setLayout(pnlNumerosLayout);

    btnNum1.setBackground(new java.awt.Color(0, 0, 0));
    btnNum1.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
    btnNum1.setForeground(new java.awt.Color(255, 255, 255));
    btnNum1.setText("1");
    btnNum1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
    btnNum1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNum1.setMaximumSize(new java.awt.Dimension(100, 100));
    btnNum1.setMinimumSize(new java.awt.Dimension(50, 50));
    btnNum1.setPreferredSize(new java.awt.Dimension(100, 100));
    btnNum1.setVerifyInputWhenFocusTarget(false);
    btnNum1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnNum1ActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    pnlNumeros.add(btnNum1, gridBagConstraints);

    btnNum2.setBackground(new java.awt.Color(0, 0, 0));
    btnNum2.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
    btnNum2.setForeground(new java.awt.Color(255, 255, 255));
    btnNum2.setText("2");
    btnNum2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
    btnNum2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNum2.setMaximumSize(new java.awt.Dimension(100, 100));
    btnNum2.setMinimumSize(new java.awt.Dimension(50, 50));
    btnNum2.setPreferredSize(new java.awt.Dimension(100, 100));
    btnNum2.setVerifyInputWhenFocusTarget(false);
    btnNum2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnNum2ActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    pnlNumeros.add(btnNum2, gridBagConstraints);

    btnNum3.setBackground(new java.awt.Color(0, 0, 0));
    btnNum3.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
    btnNum3.setForeground(new java.awt.Color(255, 255, 255));
    btnNum3.setText("3");
    btnNum3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
    btnNum3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNum3.setMaximumSize(new java.awt.Dimension(100, 100));
    btnNum3.setMinimumSize(new java.awt.Dimension(50, 50));
    btnNum3.setPreferredSize(new java.awt.Dimension(100, 100));
    btnNum3.setVerifyInputWhenFocusTarget(false);
    btnNum3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnNum3ActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 0;
    pnlNumeros.add(btnNum3, gridBagConstraints);

    btnNum4.setBackground(new java.awt.Color(0, 0, 0));
    btnNum4.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
    btnNum4.setForeground(new java.awt.Color(255, 255, 255));
    btnNum4.setText("4");
    btnNum4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
    btnNum4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNum4.setMaximumSize(new java.awt.Dimension(100, 100));
    btnNum4.setMinimumSize(new java.awt.Dimension(50, 50));
    btnNum4.setPreferredSize(new java.awt.Dimension(100, 100));
    btnNum4.setVerifyInputWhenFocusTarget(false);
    btnNum4.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnNum4ActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    pnlNumeros.add(btnNum4, gridBagConstraints);

    btnNum5.setBackground(new java.awt.Color(0, 0, 0));
    btnNum5.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
    btnNum5.setForeground(new java.awt.Color(255, 255, 255));
    btnNum5.setText("5");
    btnNum5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
    btnNum5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNum5.setMaximumSize(new java.awt.Dimension(100, 100));
    btnNum5.setMinimumSize(new java.awt.Dimension(50, 50));
    btnNum5.setPreferredSize(new java.awt.Dimension(100, 100));
    btnNum5.setVerifyInputWhenFocusTarget(false);
    btnNum5.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnNum5ActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    pnlNumeros.add(btnNum5, gridBagConstraints);

    btnNum6.setBackground(new java.awt.Color(0, 0, 0));
    btnNum6.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
    btnNum6.setForeground(new java.awt.Color(255, 255, 255));
    btnNum6.setText("6");
    btnNum6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
    btnNum6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNum6.setMaximumSize(new java.awt.Dimension(100, 100));
    btnNum6.setMinimumSize(new java.awt.Dimension(50, 50));
    btnNum6.setPreferredSize(new java.awt.Dimension(100, 100));
    btnNum6.setVerifyInputWhenFocusTarget(false);
    btnNum6.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnNum6ActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 2;
    pnlNumeros.add(btnNum6, gridBagConstraints);

    btnNum7.setBackground(new java.awt.Color(0, 0, 0));
    btnNum7.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
    btnNum7.setForeground(new java.awt.Color(255, 255, 255));
    btnNum7.setText("7");
    btnNum7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
    btnNum7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNum7.setMaximumSize(new java.awt.Dimension(100, 100));
    btnNum7.setMinimumSize(new java.awt.Dimension(50, 50));
    btnNum7.setPreferredSize(new java.awt.Dimension(100, 100));
    btnNum7.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnNum7ActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    pnlNumeros.add(btnNum7, gridBagConstraints);

    btnNum8.setBackground(new java.awt.Color(0, 0, 0));
    btnNum8.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
    btnNum8.setForeground(new java.awt.Color(255, 255, 255));
    btnNum8.setText("8");
    btnNum8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
    btnNum8.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNum8.setMaximumSize(new java.awt.Dimension(100, 100));
    btnNum8.setMinimumSize(new java.awt.Dimension(50, 50));
    btnNum8.setPreferredSize(new java.awt.Dimension(100, 100));
    btnNum8.setVerifyInputWhenFocusTarget(false);
    btnNum8.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnNum8ActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 4;
    pnlNumeros.add(btnNum8, gridBagConstraints);

    btnNum9.setBackground(new java.awt.Color(0, 0, 0));
    btnNum9.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
    btnNum9.setForeground(new java.awt.Color(255, 255, 255));
    btnNum9.setText("9");
    btnNum9.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
    btnNum9.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNum9.setMaximumSize(new java.awt.Dimension(100, 100));
    btnNum9.setMinimumSize(new java.awt.Dimension(50, 50));
    btnNum9.setPreferredSize(new java.awt.Dimension(100, 100));
    btnNum9.setVerifyInputWhenFocusTarget(false);
    btnNum9.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnNum9ActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 4;
    pnlNumeros.add(btnNum9, gridBagConstraints);

    btnNum0.setBackground(new java.awt.Color(0, 0, 0));
    btnNum0.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
    btnNum0.setForeground(new java.awt.Color(255, 255, 255));
    btnNum0.setText("0");
    btnNum0.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
    btnNum0.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNum0.setMaximumSize(new java.awt.Dimension(100, 100));
    btnNum0.setMinimumSize(new java.awt.Dimension(50, 50));
    btnNum0.setPreferredSize(new java.awt.Dimension(100, 100));
    btnNum0.setVerifyInputWhenFocusTarget(false);
    btnNum0.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnNum0ActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 6;
    pnlNumeros.add(btnNum0, gridBagConstraints);

    pnlTeclado.add(pnlNumeros, java.awt.BorderLayout.CENTER);

    pnlButoesAcao.setBackground(new java.awt.Color(0, 0, 0));
    pnlButoesAcao.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2));
    pnlButoesAcao.setInheritsPopupMenu(true);
    pnlButoesAcao.setMinimumSize(new java.awt.Dimension(50, 50));
    pnlButoesAcao.setPreferredSize(new java.awt.Dimension(75, 75));
    pnlButoesAcao.setRequestFocusEnabled(false);
    pnlButoesAcao.setLayout(new java.awt.GridLayout(1, 0, 5, 5));

    btnBranco.setBackground(new java.awt.Color(255, 255, 255));
    btnBranco.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
    btnBranco.setText("Branco");
    btnBranco.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 3));
    btnBranco.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnBranco.setMaximumSize(new java.awt.Dimension(100, 100));
    btnBranco.setMinimumSize(new java.awt.Dimension(50, 50));
    btnBranco.setPreferredSize(new java.awt.Dimension(100, 100));
    btnBranco.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnBrancoActionPerformed(evt);
      }
    });
    pnlButoesAcao.add(btnBranco);

    btnCorrige.setBackground(new java.awt.Color(230, 61, 4));
    btnCorrige.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
    btnCorrige.setText("Corrige");
    btnCorrige.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 3));
    btnCorrige.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnCorrige.setMaximumSize(new java.awt.Dimension(100, 100));
    btnCorrige.setMinimumSize(new java.awt.Dimension(50, 50));
    btnCorrige.setPreferredSize(new java.awt.Dimension(100, 100));
    btnCorrige.setRequestFocusEnabled(false);
    btnCorrige.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnCorrigeActionPerformed(evt);
      }
    });
    pnlButoesAcao.add(btnCorrige);

    btnConfirma.setBackground(new java.awt.Color(0, 204, 0));
    btnConfirma.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
    btnConfirma.setText("Confirma");
    btnConfirma.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 3));
    btnConfirma.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnConfirma.setMaximumSize(new java.awt.Dimension(100, 100));
    btnConfirma.setMinimumSize(new java.awt.Dimension(50, 50));
    btnConfirma.setPreferredSize(new java.awt.Dimension(100, 100));
    btnConfirma.setRequestFocusEnabled(false);
    btnConfirma.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnConfirmaActionPerformed(evt);
      }
    });
    pnlButoesAcao.add(btnConfirma);

    pnlTeclado.add(pnlButoesAcao, java.awt.BorderLayout.SOUTH);

    pnlCenter.add(pnlTeclado, java.awt.BorderLayout.EAST);

    pnlDetalheVotacao.setLayout(new java.awt.CardLayout());

    pnlDadosCadidato.setBackground(new java.awt.Color(255, 255, 255));
    pnlDadosCadidato.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2));
    pnlDadosCadidato.setMinimumSize(new java.awt.Dimension(700, 700));
    pnlDadosCadidato.setLayout(new java.awt.BorderLayout());

    pnlCandidatoTop.setMinimumSize(new java.awt.Dimension(250, 250));
    pnlCandidatoTop.setPreferredSize(new java.awt.Dimension(250, 250));
    pnlCandidatoTop.setLayout(new java.awt.BorderLayout());

    pnlFotoCandidato.setBackground(new java.awt.Color(204, 204, 204));
    pnlFotoCandidato.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(88, 87, 87)));
    pnlFotoCandidato.setMinimumSize(new java.awt.Dimension(200, 200));
    pnlFotoCandidato.setPreferredSize(new java.awt.Dimension(200, 200));
    pnlFotoCandidato.setLayout(new java.awt.BorderLayout());

    lblFotoCandidato.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblFotoCandidato.setMaximumSize(new java.awt.Dimension(200, 200));
    lblFotoCandidato.setMinimumSize(new java.awt.Dimension(200, 200));
    lblFotoCandidato.setPreferredSize(new java.awt.Dimension(200, 200));
    pnlFotoCandidato.add(lblFotoCandidato, java.awt.BorderLayout.CENTER);

    lblTextoCandidato.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    lblTextoCandidato.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblTextoCandidato.setText("lblTextoCandidato");
    lblTextoCandidato.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    lblTextoCandidato.setMaximumSize(new java.awt.Dimension(30, 30));
    lblTextoCandidato.setMinimumSize(new java.awt.Dimension(30, 30));
    lblTextoCandidato.setPreferredSize(new java.awt.Dimension(30, 30));
    pnlFotoCandidato.add(lblTextoCandidato, java.awt.BorderLayout.SOUTH);

    pnlCandidatoTop.add(pnlFotoCandidato, java.awt.BorderLayout.EAST);

    pnlCargo.setMinimumSize(new java.awt.Dimension(200, 200));
    pnlCargo.setPreferredSize(new java.awt.Dimension(200, 200));

    lblSeuVoto.setFont(new java.awt.Font("Segoe UI", 0, 24)); // NOI18N
    lblSeuVoto.setText("SEU VOTO PARA");

    lblCargo.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N
    lblCargo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblCargo.setText("lblCargo");

    lblNumero.setFont(new java.awt.Font("Segoe UI", 0, 20)); // NOI18N
    lblNumero.setText("Número:");

    pnlInputNumeros.setMaximumSize(new java.awt.Dimension(250, 60));
    pnlInputNumeros.setMinimumSize(new java.awt.Dimension(250, 60));
    pnlInputNumeros.setPreferredSize(new java.awt.Dimension(250, 60));
    pnlInputNumeros.setLayout(new java.awt.GridLayout(1, 0, 5, 0));

    lblNum1.setFont(new java.awt.Font("Segoe UI", 1, 40)); // NOI18N
    lblNum1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblNum1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    lblNum1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
      public void propertyChange(java.beans.PropertyChangeEvent evt) {
        lblNum1PropertyChange(evt);
      }
    });
    pnlInputNumeros.add(lblNum1);

    lblNum2.setFont(new java.awt.Font("Segoe UI", 1, 40)); // NOI18N
    lblNum2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblNum2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    lblNum2.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
      public void propertyChange(java.beans.PropertyChangeEvent evt) {
        lblNum2PropertyChange(evt);
      }
    });
    pnlInputNumeros.add(lblNum2);

    lblNum3.setFont(new java.awt.Font("Segoe UI", 1, 40)); // NOI18N
    lblNum3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblNum3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    lblNum3.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
      public void propertyChange(java.beans.PropertyChangeEvent evt) {
        lblNum3PropertyChange(evt);
      }
    });
    pnlInputNumeros.add(lblNum3);

    lblNum4.setFont(new java.awt.Font("Segoe UI", 1, 40)); // NOI18N
    lblNum4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblNum4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    lblNum4.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
      public void propertyChange(java.beans.PropertyChangeEvent evt) {
        lblNum4PropertyChange(evt);
      }
    });
    pnlInputNumeros.add(lblNum4);

    lblNum5.setFont(new java.awt.Font("Segoe UI", 1, 40)); // NOI18N
    lblNum5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblNum5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    lblNum5.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
      public void propertyChange(java.beans.PropertyChangeEvent evt) {
        lblNum5PropertyChange(evt);
      }
    });
    pnlInputNumeros.add(lblNum5);

    javax.swing.GroupLayout pnlCargoLayout = new javax.swing.GroupLayout(pnlCargo);
    pnlCargo.setLayout(pnlCargoLayout);
    pnlCargoLayout.setHorizontalGroup(
      pnlCargoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(pnlCargoLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(pnlCargoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(lblCargo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addGroup(pnlCargoLayout.createSequentialGroup()
            .addGroup(pnlCargoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(lblSeuVoto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
              .addGroup(pnlCargoLayout.createSequentialGroup()
                .addComponent(lblNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnlInputNumeros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 8, Short.MAX_VALUE)))
            .addContainerGap())))
    );
    pnlCargoLayout.setVerticalGroup(
      pnlCargoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(pnlCargoLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(lblSeuVoto, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE)
        .addComponent(lblCargo, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addGap(33, 33, 33)
        .addGroup(pnlCargoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
          .addComponent(lblNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(pnlInputNumeros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addGap(44, 44, 44))
    );

    pnlCandidatoTop.add(pnlCargo, java.awt.BorderLayout.CENTER);

    pnlDadosCadidato.add(pnlCandidatoTop, java.awt.BorderLayout.NORTH);

    pnlCandidatoCenter.setLayout(new java.awt.BorderLayout());

    pnlNomeCandidato.setLayout(new java.awt.GridLayout(7, 0, 10, 10));

    lblNomeCandidato.setFont(new java.awt.Font("Segoe UI", 0, 24)); // NOI18N
    lblNomeCandidato.setText("lblNomeCandidato");
    pnlNomeCandidato.add(lblNomeCandidato);

    lblPartido.setFont(new java.awt.Font("Segoe UI", 0, 20)); // NOI18N
    lblPartido.setText("lblPartido");
    pnlNomeCandidato.add(lblPartido);

    lblVicePriSuplenteNome.setFont(new java.awt.Font("Segoe UI", 0, 20)); // NOI18N
    lblVicePriSuplenteNome.setText("lblVicePriSuplenteNome");
    pnlNomeCandidato.add(lblVicePriSuplenteNome);

    lblSegSuplenteNome.setFont(new java.awt.Font("Segoe UI", 0, 20)); // NOI18N
    lblSegSuplenteNome.setText("lblSegSuplenteNome");
    pnlNomeCandidato.add(lblSegSuplenteNome);

    pnlCandidatoCenter.add(pnlNomeCandidato, java.awt.BorderLayout.CENTER);

    jPanel2.setMinimumSize(new java.awt.Dimension(300, 300));
    jPanel2.setPreferredSize(new java.awt.Dimension(300, 300));
    jPanel2.setLayout(null);

    pnlFotoSegSuplente.setBackground(new java.awt.Color(204, 204, 204));
    pnlFotoSegSuplente.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(88, 87, 87)));
    pnlFotoSegSuplente.setMaximumSize(new java.awt.Dimension(125, 150));
    pnlFotoSegSuplente.setMinimumSize(new java.awt.Dimension(125, 150));
    pnlFotoSegSuplente.setPreferredSize(new java.awt.Dimension(125, 150));
    pnlFotoSegSuplente.setLayout(new java.awt.BorderLayout());

    lblFotoSegSuplente.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    pnlFotoSegSuplente.add(lblFotoSegSuplente, java.awt.BorderLayout.CENTER);

    lblTextoFotoSegSuplente.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
    lblTextoFotoSegSuplente.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblTextoFotoSegSuplente.setText("lblTextoSegSuplente");
    lblTextoFotoSegSuplente.setMaximumSize(new java.awt.Dimension(30, 30));
    lblTextoFotoSegSuplente.setMinimumSize(new java.awt.Dimension(30, 30));
    lblTextoFotoSegSuplente.setPreferredSize(new java.awt.Dimension(30, 30));
    pnlFotoSegSuplente.add(lblTextoFotoSegSuplente, java.awt.BorderLayout.SOUTH);

    jPanel2.add(pnlFotoSegSuplente);
    pnlFotoSegSuplente.setBounds(10, 11, 133, 185);

    pnlFotoVicePriSuplente.setBackground(new java.awt.Color(204, 204, 204));
    pnlFotoVicePriSuplente.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(88, 87, 87)));
    pnlFotoVicePriSuplente.setMaximumSize(new java.awt.Dimension(125, 150));
    pnlFotoVicePriSuplente.setMinimumSize(new java.awt.Dimension(125, 150));
    pnlFotoVicePriSuplente.setPreferredSize(new java.awt.Dimension(125, 150));
    pnlFotoVicePriSuplente.setLayout(new java.awt.BorderLayout());

    lblFotoVicePriSuplente.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    pnlFotoVicePriSuplente.add(lblFotoVicePriSuplente, java.awt.BorderLayout.CENTER);

    lblTextoFotoVicePriSuplente.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
    lblTextoFotoVicePriSuplente.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblTextoFotoVicePriSuplente.setText("lblTextoVice");
    lblTextoFotoVicePriSuplente.setMaximumSize(new java.awt.Dimension(30, 30));
    lblTextoFotoVicePriSuplente.setMinimumSize(new java.awt.Dimension(30, 30));
    lblTextoFotoVicePriSuplente.setPreferredSize(new java.awt.Dimension(30, 30));
    pnlFotoVicePriSuplente.add(lblTextoFotoVicePriSuplente, java.awt.BorderLayout.SOUTH);

    jPanel2.add(pnlFotoVicePriSuplente);
    pnlFotoVicePriSuplente.setBounds(149, 11, 141, 185);

    pnlCandidatoCenter.add(jPanel2, java.awt.BorderLayout.EAST);

    pnlDadosCadidato.add(pnlCandidatoCenter, java.awt.BorderLayout.CENTER);

    pnlCandidatoButton.setMinimumSize(new java.awt.Dimension(120, 120));
    pnlCandidatoButton.setPreferredSize(new java.awt.Dimension(120, 120));
    pnlCandidatoButton.setLayout(new java.awt.GridLayout(4, 0, 0, 5));
    pnlCandidatoButton.add(jSeparator1);

    lblAperte.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
    lblAperte.setText("Aperte a Tecla");

    javax.swing.GroupLayout pnlHelpTopLayout = new javax.swing.GroupLayout(pnlHelpTop);
    pnlHelpTop.setLayout(pnlHelpTopLayout);
    pnlHelpTopLayout.setHorizontalGroup(
      pnlHelpTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(pnlHelpTopLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(lblAperte, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(229, Short.MAX_VALUE))
    );
    pnlHelpTopLayout.setVerticalGroup(
      pnlHelpTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(pnlHelpTopLayout.createSequentialGroup()
        .addComponent(lblAperte)
        .addGap(0, 1, Short.MAX_VALUE))
    );

    pnlCandidatoButton.add(pnlHelpTop);

    lblTextoBotaoVerde.setFont(new java.awt.Font("Segoe UI", 0, 20)); // NOI18N
    lblTextoBotaoVerde.setText("VERDE para CONFIRMAR este voto ");

    javax.swing.GroupLayout pnlHelpCenterLayout = new javax.swing.GroupLayout(pnlHelpCenter);
    pnlHelpCenter.setLayout(pnlHelpCenterLayout);
    pnlHelpCenterLayout.setHorizontalGroup(
      pnlHelpCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(pnlHelpCenterLayout.createSequentialGroup()
        .addGap(71, 71, 71)
        .addComponent(lblTextoBotaoVerde, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    pnlHelpCenterLayout.setVerticalGroup(
      pnlHelpCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlHelpCenterLayout.createSequentialGroup()
        .addGap(0, 0, Short.MAX_VALUE)
        .addComponent(lblTextoBotaoVerde))
    );

    pnlCandidatoButton.add(pnlHelpCenter);

    lblTextoBotaoLaranja.setFont(new java.awt.Font("Segoe UI", 0, 20)); // NOI18N
    lblTextoBotaoLaranja.setText("LARANJA para REINICIAR este voto");

    javax.swing.GroupLayout pnlHelpButtonLayout = new javax.swing.GroupLayout(pnlHelpButton);
    pnlHelpButton.setLayout(pnlHelpButtonLayout);
    pnlHelpButtonLayout.setHorizontalGroup(
      pnlHelpButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(pnlHelpButtonLayout.createSequentialGroup()
        .addGap(46, 46, 46)
        .addComponent(lblTextoBotaoLaranja, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    pnlHelpButtonLayout.setVerticalGroup(
      pnlHelpButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlHelpButtonLayout.createSequentialGroup()
        .addGap(0, 0, Short.MAX_VALUE)
        .addComponent(lblTextoBotaoLaranja))
    );

    pnlCandidatoButton.add(pnlHelpButton);

    pnlDadosCadidato.add(pnlCandidatoButton, java.awt.BorderLayout.SOUTH);

    pnlDetalheVotacao.add(pnlDadosCadidato, "pnlDadosCadidato");

    pnlFimVotacao.setLayout(new java.awt.GridLayout(3, 0));

    javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(
      jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 582, Short.MAX_VALUE)
    );
    jPanel4Layout.setVerticalGroup(
      jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 166, Short.MAX_VALUE)
    );

    pnlFimVotacao.add(jPanel4);

    jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 160)); // NOI18N
    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText("FIM");
    jLabel1.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
    pnlFimVotacao.add(jLabel1);

    jButton1.setBackground(new java.awt.Color(0, 153, 204));
    jButton1.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
    jButton1.setForeground(new java.awt.Color(255, 255, 255));
    jButton1.setText("Novo Voto");
    jButton1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton1ActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
    jPanel5.setLayout(jPanel5Layout);
    jPanel5Layout.setHorizontalGroup(
      jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
        .addGap(0, 468, Short.MAX_VALUE)
        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
    );
    jPanel5Layout.setVerticalGroup(
      jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
        .addGap(0, 127, Short.MAX_VALUE)
        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
    );

    pnlFimVotacao.add(jPanel5);

    pnlDetalheVotacao.add(pnlFimVotacao, "pnlFimVotacao");

    pnlCenter.add(pnlDetalheVotacao, java.awt.BorderLayout.CENTER);

    pnlVotacao.add(pnlCenter, java.awt.BorderLayout.CENTER);

    pnlTop.setBackground(new java.awt.Color(0, 51, 51));
    pnlTop.setPreferredSize(new java.awt.Dimension(40, 40));
    pnlTop.setRequestFocusEnabled(false);

    javax.swing.GroupLayout pnlTopLayout = new javax.swing.GroupLayout(pnlTop);
    pnlTop.setLayout(pnlTopLayout);
    pnlTopLayout.setHorizontalGroup(
      pnlTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 1104, Short.MAX_VALUE)
    );
    pnlTopLayout.setVerticalGroup(
      pnlTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 40, Short.MAX_VALUE)
    );

    pnlVotacao.add(pnlTop, java.awt.BorderLayout.NORTH);

    pnlBotton.setBackground(new java.awt.Color(0, 51, 51));
    pnlBotton.setPreferredSize(new java.awt.Dimension(40, 40));

    javax.swing.GroupLayout pnlBottonLayout = new javax.swing.GroupLayout(pnlBotton);
    pnlBotton.setLayout(pnlBottonLayout);
    pnlBottonLayout.setHorizontalGroup(
      pnlBottonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 1104, Short.MAX_VALUE)
    );
    pnlBottonLayout.setVerticalGroup(
      pnlBottonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 40, Short.MAX_VALUE)
    );

    pnlVotacao.add(pnlBotton, java.awt.BorderLayout.SOUTH);

    pnlRigth.setBackground(new java.awt.Color(0, 51, 51));
    pnlRigth.setPreferredSize(new java.awt.Dimension(40, 40));

    javax.swing.GroupLayout pnlRigthLayout = new javax.swing.GroupLayout(pnlRigth);
    pnlRigth.setLayout(pnlRigthLayout);
    pnlRigthLayout.setHorizontalGroup(
      pnlRigthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 40, Short.MAX_VALUE)
    );
    pnlRigthLayout.setVerticalGroup(
      pnlRigthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 500, Short.MAX_VALUE)
    );

    pnlVotacao.add(pnlRigth, java.awt.BorderLayout.EAST);

    pnlLeft.setBackground(new java.awt.Color(0, 51, 51));
    pnlLeft.setPreferredSize(new java.awt.Dimension(40, 40));

    javax.swing.GroupLayout pnlLeftLayout = new javax.swing.GroupLayout(pnlLeft);
    pnlLeft.setLayout(pnlLeftLayout);
    pnlLeftLayout.setHorizontalGroup(
      pnlLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 40, Short.MAX_VALUE)
    );
    pnlLeftLayout.setVerticalGroup(
      pnlLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 500, Short.MAX_VALUE)
    );

    pnlVotacao.add(pnlLeft, java.awt.BorderLayout.WEST);
    pnlLeft.getAccessibleContext().setAccessibleName("");

    jPanelInfoEleitor.setLayout(new java.awt.BorderLayout());

    jPanel1.setBackground(new java.awt.Color(0, 51, 51));
    jPanel1.setMaximumSize(new java.awt.Dimension(50, 50));
    jPanel1.setMinimumSize(new java.awt.Dimension(50, 50));
    jPanel1.setPreferredSize(new java.awt.Dimension(50, 50));
    jPanel1.setLayout(new java.awt.GridLayout(1, 0));

    jLabelTitulo.setBackground(new java.awt.Color(0, 51, 51));
    jLabelTitulo.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
    jLabelTitulo.setForeground(new java.awt.Color(255, 255, 255));
    jLabelTitulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabelTitulo.setText("Dados do Eleitor");
    jPanel1.add(jLabelTitulo);

    jPanelInfoEleitor.add(jPanel1, java.awt.BorderLayout.NORTH);

    jPanel3.setBackground(new java.awt.Color(0, 51, 51));
    jPanel3.setLayout(new java.awt.BorderLayout());

    jPanel9.setBackground(new java.awt.Color(0, 51, 51));
    jPanel9.setMinimumSize(new java.awt.Dimension(300, 300));
    jPanel9.setPreferredSize(new java.awt.Dimension(300, 300));
    jPanel9.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    jLabelNomeEleitor.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jLabelNomeEleitor.setForeground(new java.awt.Color(255, 255, 255));
    jLabelNomeEleitor.setText("Nome");
    jPanel9.add(jLabelNomeEleitor, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));

    jTextFieldNomeEleitor.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
    jTextFieldNomeEleitor.setBorder(null);
    jTextFieldNomeEleitor.setPreferredSize(new java.awt.Dimension(200, 30));
    jPanel9.add(jTextFieldNomeEleitor, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 35, 400, -1));

    jLabelCpfEleitor.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jLabelCpfEleitor.setForeground(new java.awt.Color(255, 255, 255));
    jLabelCpfEleitor.setText("Cpf");
    jPanel9.add(jLabelCpfEleitor, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, -1, -1));

    jFormattedTextFieldCpf.setBorder(null);
    try {
      jFormattedTextFieldCpf.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###########")));
    } catch (java.text.ParseException ex) {
      ex.printStackTrace();
    }
    jFormattedTextFieldCpf.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
    jFormattedTextFieldCpf.setPreferredSize(new java.awt.Dimension(70, 30));
    jPanel9.add(jFormattedTextFieldCpf, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 95, 150, 30));

    jLabelTituloEleitor.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jLabelTituloEleitor.setForeground(new java.awt.Color(255, 255, 255));
    jLabelTituloEleitor.setText("Número do Título");
    jPanel9.add(jLabelTituloEleitor, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 130, -1, -1));

    jFormattedTextFieldTitulo.setBorder(null);
    try {
      jFormattedTextFieldTitulo.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("############")));
    } catch (java.text.ParseException ex) {
      ex.printStackTrace();
    }
    jFormattedTextFieldTitulo.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
    jPanel9.add(jFormattedTextFieldTitulo, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 155, 150, 30));

    jLabelRgEleitor.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jLabelRgEleitor.setForeground(new java.awt.Color(255, 255, 255));
    jLabelRgEleitor.setText("RG");
    jPanel9.add(jLabelRgEleitor, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 190, -1, -1));

    jFormattedTextFieldRg.setBorder(null);
    try {
      jFormattedTextFieldRg.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###########")));
    } catch (java.text.ParseException ex) {
      ex.printStackTrace();
    }
    jFormattedTextFieldRg.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
    jPanel9.add(jFormattedTextFieldRg, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 215, 150, 30));

    jPanel3.add(jPanel9, java.awt.BorderLayout.PAGE_START);

    jPanel10.setBackground(new java.awt.Color(0, 51, 51));

    javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
    jPanel10.setLayout(jPanel10Layout);
    jPanel10Layout.setHorizontalGroup(
      jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 708, Short.MAX_VALUE)
    );
    jPanel10Layout.setVerticalGroup(
      jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 12, Short.MAX_VALUE)
    );

    jPanel3.add(jPanel10, java.awt.BorderLayout.CENTER);

    jPanelInfoEleitor.add(jPanel3, java.awt.BorderLayout.CENTER);

    jPanel6.setBackground(new java.awt.Color(0, 51, 51));
    jPanel6.setMaximumSize(new java.awt.Dimension(75, 75));
    jPanel6.setMinimumSize(new java.awt.Dimension(75, 75));
    jPanel6.setPreferredSize(new java.awt.Dimension(75, 75));
    jPanel6.setLayout(new java.awt.BorderLayout());

    jPanel7.setBackground(new java.awt.Color(0, 51, 51));

    jButtonPerfil.setBackground(new java.awt.Color(0, 153, 204));
    jButtonPerfil.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
    jButtonPerfil.setForeground(new java.awt.Color(255, 255, 255));
    jButtonPerfil.setText("Selecionar Perfil");
    jButtonPerfil.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonPerfil.setMaximumSize(new java.awt.Dimension(200, 40));
    jButtonPerfil.setMinimumSize(new java.awt.Dimension(200, 40));
    jButtonPerfil.setPreferredSize(new java.awt.Dimension(200, 40));
    jButtonPerfil.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonPerfilActionPerformed(evt);
      }
    });
    jPanel7.add(jButtonPerfil);

    jButtonVotar.setBackground(new java.awt.Color(0, 153, 204));
    jButtonVotar.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
    jButtonVotar.setForeground(new java.awt.Color(255, 255, 255));
    jButtonVotar.setText("Votar");
    jButtonVotar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonVotar.setMaximumSize(new java.awt.Dimension(200, 40));
    jButtonVotar.setMinimumSize(new java.awt.Dimension(200, 40));
    jButtonVotar.setPreferredSize(new java.awt.Dimension(200, 40));
    jButtonVotar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonVotarActionPerformed(evt);
      }
    });
    jPanel7.add(jButtonVotar);

    jPanel6.add(jPanel7, java.awt.BorderLayout.CENTER);

    jPanel8.setBackground(new java.awt.Color(0, 51, 51));
    jPanel8.setPreferredSize(new java.awt.Dimension(25, 25));
    jPanel8.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    jLabelCamposEleitor.setBackground(new java.awt.Color(0, 51, 51));
    jLabelCamposEleitor.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
    jLabelCamposEleitor.setForeground(new java.awt.Color(255, 255, 255));
    jLabelCamposEleitor.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jPanel8.add(jLabelCamposEleitor, new org.netbeans.lib.awtextra.AbsoluteConstraints(8, 0, 690, 25));

    jPanel6.add(jPanel8, java.awt.BorderLayout.SOUTH);

    jPanelInfoEleitor.add(jPanel6, java.awt.BorderLayout.SOUTH);

    jPanelAdministrador.setName(""); // NOI18N
    jPanelAdministrador.setLayout(new java.awt.BorderLayout());

    jPanel11.setBackground(new java.awt.Color(0, 51, 51));
    jPanel11.setLayout(new java.awt.GridLayout(3, 2, 0, 15));

    jButtonCandidato.setBackground(new java.awt.Color(0, 153, 204));
    jButtonCandidato.setFont(new java.awt.Font("Segoe UI", 0, 36)); // NOI18N
    jButtonCandidato.setForeground(new java.awt.Color(255, 255, 255));
    jButtonCandidato.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/1415396104_People.png"))); // NOI18N
    jButtonCandidato.setText("Candidatos");
    jButtonCandidato.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonCandidato.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jButtonCandidato.setPreferredSize(new java.awt.Dimension(250, 100));
    jButtonCandidato.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    jButtonCandidato.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonCandidatoActionPerformed(evt);
      }
    });
    jPanel11.add(jButtonCandidato);

    jButtonCargo.setBackground(new java.awt.Color(0, 153, 204));
    jButtonCargo.setFont(new java.awt.Font("Segoe UI", 0, 36)); // NOI18N
    jButtonCargo.setForeground(new java.awt.Color(255, 255, 255));
    jButtonCargo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/1415396229_Users_Group.png"))); // NOI18N
    jButtonCargo.setText("Cargos");
    jButtonCargo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonCargo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jButtonCargo.setPreferredSize(new java.awt.Dimension(250, 100));
    jButtonCargo.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jButtonCargo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    jButtonCargo.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonCargoActionPerformed(evt);
      }
    });
    jPanel11.add(jButtonCargo);

    jButtonApuracao.setBackground(new java.awt.Color(0, 153, 204));
    jButtonApuracao.setFont(new java.awt.Font("Segoe UI", 0, 36)); // NOI18N
    jButtonApuracao.setForeground(new java.awt.Color(255, 255, 255));
    jButtonApuracao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/1415396844_Supervisor.png"))); // NOI18N
    jButtonApuracao.setText("Apuração");
    jButtonApuracao.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonApuracao.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jButtonApuracao.setPreferredSize(new java.awt.Dimension(250, 100));
    jButtonApuracao.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jButtonApuracao.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    jButtonApuracao.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonApuracaoActionPerformed(evt);
      }
    });
    jPanel11.add(jButtonApuracao);

    jPanelAdministrador.add(jPanel11, java.awt.BorderLayout.CENTER);

    jPanel12.setBackground(new java.awt.Color(0, 51, 51));
    jPanel12.setMinimumSize(new java.awt.Dimension(200, 200));
    jPanel12.setPreferredSize(new java.awt.Dimension(200, 200));
    jPanel12.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 10));
    jPanelAdministrador.add(jPanel12, java.awt.BorderLayout.NORTH);

    jPanel13.setBackground(new java.awt.Color(0, 51, 51));
    jPanel13.setMinimumSize(new java.awt.Dimension(200, 200));
    jPanel13.setPreferredSize(new java.awt.Dimension(200, 200));

    jButtonPerfil1.setBackground(new java.awt.Color(0, 153, 204));
    jButtonPerfil1.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
    jButtonPerfil1.setForeground(new java.awt.Color(255, 255, 255));
    jButtonPerfil1.setText("Selecionar Perfil");
    jButtonPerfil1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonPerfil1.setMaximumSize(new java.awt.Dimension(200, 40));
    jButtonPerfil1.setMinimumSize(new java.awt.Dimension(200, 40));
    jButtonPerfil1.setPreferredSize(new java.awt.Dimension(200, 40));
    jButtonPerfil1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonPerfil1ActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
    jPanel13.setLayout(jPanel13Layout);
    jPanel13Layout.setHorizontalGroup(
      jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
        .addContainerGap(640, Short.MAX_VALUE)
        .addComponent(jButtonPerfil1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap())
    );
    jPanel13Layout.setVerticalGroup(
      jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel13Layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jButtonPerfil1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(149, Short.MAX_VALUE))
    );

    jPanelAdministrador.add(jPanel13, java.awt.BorderLayout.SOUTH);

    jPanel14.setBackground(new java.awt.Color(0, 51, 51));
    jPanel14.setMinimumSize(new java.awt.Dimension(200, 200));
    jPanel14.setPreferredSize(new java.awt.Dimension(300, 300));

    javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
    jPanel14.setLayout(jPanel14Layout);
    jPanel14Layout.setHorizontalGroup(
      jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 300, Short.MAX_VALUE)
    );
    jPanel14Layout.setVerticalGroup(
      jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 387, Short.MAX_VALUE)
    );

    jPanelAdministrador.add(jPanel14, java.awt.BorderLayout.WEST);

    jPanel15.setBackground(new java.awt.Color(0, 51, 51));
    jPanel15.setMinimumSize(new java.awt.Dimension(200, 200));
    jPanel15.setPreferredSize(new java.awt.Dimension(300, 300));

    javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
    jPanel15.setLayout(jPanel15Layout);
    jPanel15Layout.setHorizontalGroup(
      jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 300, Short.MAX_VALUE)
    );
    jPanel15Layout.setVerticalGroup(
      jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 387, Short.MAX_VALUE)
    );

    jPanelAdministrador.add(jPanel15, java.awt.BorderLayout.EAST);

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setPreferredSize(new java.awt.Dimension(1024, 768));

    jPanelFrame.setLayout(new java.awt.BorderLayout());

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jPanelFrame, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jPanelFrame, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );

    pack();
  }// </editor-fold>//GEN-END:initComponents

    private void jButtonCargoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCargoActionPerformed
      CadastroCargo viewCargo = new CadastroCargo(this, true);
      viewCargo.setVisible(true);
    }//GEN-LAST:event_jButtonCargoActionPerformed

    private void jButtonCandidatoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCandidatoActionPerformed

      CadastroCandidato viewCandidato = new CadastroCandidato(this, true);

      if (Cargo.getProxId() == 1) {
        if (UrnaUtil.confirmDialog("Não existem Cargos cadastrados. Deseja cadatrar agora?", "")) {
          jButtonCargoActionPerformed(null);
        }
      } else {
        viewCandidato.setVisible(true);
      }
    }//GEN-LAST:event_jButtonCandidatoActionPerformed

    private void jButtonApuracaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonApuracaoActionPerformed
      Voto.apurar();
      Apuracao viewApuracao = new Apuracao(this, true);
      viewApuracao.setVisible(true);
    }//GEN-LAST:event_jButtonApuracaoActionPerformed


    private void jButtonVotarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVotarActionPerformed

      if (!isEmpty()) {
        if (!Eleitor.votou(UrnaUtil.retirarSimbolos(jFormattedTextFieldCpf.getText()))) {
          Eleitor.inserir(new Eleitor(jTextFieldNomeEleitor.getText(),
                  UrnaUtil.retirarSimbolos(jFormattedTextFieldCpf.getText()),
                  UrnaUtil.retirarSimbolos(jFormattedTextFieldTitulo.getText()),
                  UrnaUtil.retirarSimbolos(jFormattedTextFieldRg.getText())));
          ViewUtil.trocaPanels(jPanelFrame, pnlVotacao);
        } else {
          jLabelCamposEleitor.setText("Esse eleitor já efetuou seu voto !");
        }
      } else {
        jLabelCamposEleitor.setText("Preencha todos os campos !");
      }
    }//GEN-LAST:event_jButtonVotarActionPerformed

    private void btnNum7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNum7ActionPerformed
      if (getNumAtivo().getText().isEmpty()) {
        getNumAtivo().setText("7");
      }
    }//GEN-LAST:event_btnNum7ActionPerformed

    private void btnNum1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNum1ActionPerformed
      if (getNumAtivo().getText().isEmpty()) {
        getNumAtivo().setText("1");
      }
    }//GEN-LAST:event_btnNum1ActionPerformed

    private void lblNum1PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_lblNum1PropertyChange
      if (evt.getPropertyName().equals("text")) {
        ativaProxCampo();
      }
    }//GEN-LAST:event_lblNum1PropertyChange

  private void lblNum2PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_lblNum2PropertyChange
    if (evt.getPropertyName().equals("text")) {
      ativaProxCampo();
    }
  }//GEN-LAST:event_lblNum2PropertyChange

  private void btnNum2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNum2ActionPerformed
    if (getNumAtivo().getText().isEmpty()) {
      getNumAtivo().setText("2");
    }
  }//GEN-LAST:event_btnNum2ActionPerformed

  private void btnNum3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNum3ActionPerformed
    if (getNumAtivo().getText().isEmpty()) {
      getNumAtivo().setText("3");
    }
  }//GEN-LAST:event_btnNum3ActionPerformed

  private void btnNum4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNum4ActionPerformed
    if (getNumAtivo().getText().isEmpty()) {
      getNumAtivo().setText("4");
    }
  }//GEN-LAST:event_btnNum4ActionPerformed

  private void btnNum5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNum5ActionPerformed
    if (getNumAtivo().getText().isEmpty()) {
      getNumAtivo().setText("5");
    }
  }//GEN-LAST:event_btnNum5ActionPerformed

  private void btnNum6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNum6ActionPerformed
    if (getNumAtivo().getText().isEmpty()) {
      getNumAtivo().setText("6");
    }
  }//GEN-LAST:event_btnNum6ActionPerformed

  private void btnNum8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNum8ActionPerformed
    if (getNumAtivo().getText().isEmpty()) {
      getNumAtivo().setText("8");
    }
  }//GEN-LAST:event_btnNum8ActionPerformed

  private void btnNum9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNum9ActionPerformed
    if (getNumAtivo().getText().isEmpty()) {
      getNumAtivo().setText("9");
    }
  }//GEN-LAST:event_btnNum9ActionPerformed

  private void btnNum0ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNum0ActionPerformed
    if (getNumAtivo().getText().isEmpty()) {
      getNumAtivo().setText("0");
    }
  }//GEN-LAST:event_btnNum0ActionPerformed

  private void lblNum3PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_lblNum3PropertyChange
    if (evt.getPropertyName().equals("text")) {
      ativaProxCampo();
    }
  }//GEN-LAST:event_lblNum3PropertyChange

  private void lblNum4PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_lblNum4PropertyChange
    if (evt.getPropertyName().equals("text")) {
      ativaProxCampo();
    }
  }//GEN-LAST:event_lblNum4PropertyChange

  private void lblNum5PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_lblNum5PropertyChange
    if (evt.getPropertyName().equals("text")) {
      ativaProxCampo();
    }
  }//GEN-LAST:event_lblNum5PropertyChange

  private void btnCorrigeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCorrigeActionPerformed
    InicializeTelaVotacao(listaCargos.get(cargoAtual));
  }//GEN-LAST:event_btnCorrigeActionPerformed

  private void btnConfirmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfirmaActionPerformed
    if (votoBranco) {
      votar("-2");
    } else {
      votar(getNumCandidato());
    }
    //
    if (cargoAtual < qtdeCargos - 1){
      cargoAtual++;
      InicializeTelaVotacao(listaCargos.get(cargoAtual));
    } else {
      showFimVotacao();
    }
  }//GEN-LAST:event_btnConfirmaActionPerformed

  private void btnBrancoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrancoActionPerformed
    loadDadosCandidato("-2"); 
    votoBranco = true;
  }//GEN-LAST:event_btnBrancoActionPerformed

  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    new SelecaoPerfil().setVisible(true);
    this.dispose();    
  }//GEN-LAST:event_jButton1ActionPerformed

  private void jButtonPerfilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPerfilActionPerformed
    new SelecaoPerfil().setVisible(true);
    this.dispose();  
  }//GEN-LAST:event_jButtonPerfilActionPerformed

  private void jButtonPerfil1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPerfil1ActionPerformed
    new SelecaoPerfil().setVisible(true);
    this.dispose(); 
  }//GEN-LAST:event_jButtonPerfil1ActionPerformed

  public static void main(String args) {
    java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
        new Principal(args).setVisible(true);
      }
    });
  }
  
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JButton btnBranco;
  private javax.swing.JButton btnConfirma;
  private javax.swing.JButton btnCorrige;
  private javax.swing.JButton btnNum0;
  private javax.swing.JButton btnNum1;
  private javax.swing.JButton btnNum2;
  private javax.swing.JButton btnNum3;
  private javax.swing.JButton btnNum4;
  private javax.swing.JButton btnNum5;
  private javax.swing.JButton btnNum6;
  private javax.swing.JButton btnNum7;
  private javax.swing.JButton btnNum8;
  private javax.swing.JButton btnNum9;
  private javax.swing.JButton jButton1;
  private javax.swing.JButton jButtonApuracao;
  private javax.swing.JButton jButtonCandidato;
  private javax.swing.JButton jButtonCargo;
  private javax.swing.JButton jButtonPerfil;
  private javax.swing.JButton jButtonPerfil1;
  private javax.swing.JButton jButtonVotar;
  private javax.swing.JFormattedTextField jFormattedTextFieldCpf;
  private javax.swing.JFormattedTextField jFormattedTextFieldRg;
  private javax.swing.JFormattedTextField jFormattedTextFieldTitulo;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JLabel jLabelCamposEleitor;
  private javax.swing.JLabel jLabelCpfEleitor;
  private javax.swing.JLabel jLabelNomeEleitor;
  private javax.swing.JLabel jLabelRgEleitor;
  private javax.swing.JLabel jLabelTitulo;
  private javax.swing.JLabel jLabelTituloEleitor;
  private javax.swing.JPanel jPanel1;
  private javax.swing.JPanel jPanel10;
  private javax.swing.JPanel jPanel11;
  private javax.swing.JPanel jPanel12;
  private javax.swing.JPanel jPanel13;
  private javax.swing.JPanel jPanel14;
  private javax.swing.JPanel jPanel15;
  private javax.swing.JPanel jPanel2;
  private javax.swing.JPanel jPanel3;
  private javax.swing.JPanel jPanel4;
  private javax.swing.JPanel jPanel5;
  private javax.swing.JPanel jPanel6;
  private javax.swing.JPanel jPanel7;
  private javax.swing.JPanel jPanel8;
  private javax.swing.JPanel jPanel9;
  private javax.swing.JPanel jPanelAdministrador;
  private javax.swing.JPanel jPanelFrame;
  private javax.swing.JPanel jPanelInfoEleitor;
  private javax.swing.JSeparator jSeparator1;
  private javax.swing.JTextField jTextFieldNomeEleitor;
  private javax.swing.JLabel lblAperte;
  private javax.swing.JLabel lblCargo;
  private javax.swing.JLabel lblFotoCandidato;
  private javax.swing.JLabel lblFotoSegSuplente;
  private javax.swing.JLabel lblFotoVicePriSuplente;
  private javax.swing.JLabel lblNomeCandidato;
  private javax.swing.JLabel lblNum1;
  private javax.swing.JLabel lblNum2;
  private javax.swing.JLabel lblNum3;
  private javax.swing.JLabel lblNum4;
  private javax.swing.JLabel lblNum5;
  private javax.swing.JLabel lblNumero;
  private javax.swing.JLabel lblPartido;
  private javax.swing.JLabel lblSegSuplenteNome;
  private javax.swing.JLabel lblSeuVoto;
  private javax.swing.JLabel lblTextoBotaoLaranja;
  private javax.swing.JLabel lblTextoBotaoVerde;
  private javax.swing.JLabel lblTextoCandidato;
  private javax.swing.JLabel lblTextoFotoSegSuplente;
  private javax.swing.JLabel lblTextoFotoVicePriSuplente;
  private javax.swing.JLabel lblVicePriSuplenteNome;
  private javax.swing.JPanel pnlBotton;
  private javax.swing.JPanel pnlButoesAcao;
  private javax.swing.JPanel pnlCandidatoButton;
  private javax.swing.JPanel pnlCandidatoCenter;
  private javax.swing.JPanel pnlCandidatoTop;
  private javax.swing.JPanel pnlCargo;
  private javax.swing.JPanel pnlCenter;
  private javax.swing.JPanel pnlDadosCadidato;
  private javax.swing.JPanel pnlDetalheVotacao;
  private javax.swing.JPanel pnlFimVotacao;
  private javax.swing.JPanel pnlFotoCandidato;
  private javax.swing.JPanel pnlFotoSegSuplente;
  private javax.swing.JPanel pnlFotoVicePriSuplente;
  private javax.swing.JPanel pnlHelpButton;
  private javax.swing.JPanel pnlHelpCenter;
  private javax.swing.JPanel pnlHelpTop;
  private javax.swing.JPanel pnlInputNumeros;
  private javax.swing.JPanel pnlLeft;
  private javax.swing.JPanel pnlNomeCandidato;
  private javax.swing.JPanel pnlNumeros;
  private javax.swing.JPanel pnlRigth;
  private javax.swing.JPanel pnlTeclado;
  private javax.swing.JPanel pnlTop;
  private javax.swing.JPanel pnlVotacao;
  // End of variables declaration//GEN-END:variables

  /*
   Retorna o Label ativo para digitação
   */
  private JLabel getNumAtivo() {

    JLabel labelAux;

    switch (campoAtivo) {
      case 1:
        labelAux = lblNum1;
        break;
      case 2:
        labelAux = lblNum2;
        break;
      case 3:
        labelAux = lblNum3;
        break;
      case 4:
        labelAux = lblNum4;
        break;
      case 5:
        labelAux = lblNum5;
        break;
      default:
        labelAux = lblNum1;
    }

    return labelAux;
  }

  /*
   Retorna o label do proximo numero do candidato
   */
  private JLabel getProxCampo() {

    JLabel labelAux;

    switch (campoAtivo) {
      case 1:
        labelAux = lblNum2;
        break;
      case 2:
        labelAux = lblNum3;
        break;
      case 3:
        labelAux = lblNum4;
        break;
      case 4:
        labelAux = lblNum5;
        break;
      default:
        labelAux = lblNum1;
    }

    return labelAux;
  }

  /*
   Retorna a imformação se existe um proximo digito para o cargo.
   */
  private boolean existsProxCampo() {
    return campoAtivo < lengthNumeroCargo;
  }

  /*
   Para efeito Fade In Out do Campo atual e ativa o Efeito no próximo campo
   */
  private void ativaProxCampo() {
    if (!getNumAtivo().getText().isEmpty()) {
      ViewUtil.stopFadeInOutBorderLabel(getNumAtivo());
      if (!existsProxCampo()) {
        loadDadosCandidato(getNumCandidato());
      } else {
        ViewUtil.startFadeInOutBorderLabel(getProxCampo());
        campoAtivo = campoAtivo + 1;
      }
    }

  }

  /*
   Configura a tela para mostrar a quantidade de campos de acordo com cada candidato
   */
  private void configTamanhoNumeroCargo(int length) {
    int i = 1;
    for (Component comp : pnlInputNumeros.getComponents()) {
      if ((comp instanceof JLabel)) {
        if (i > length) {
          JLabel label = (JLabel) comp;
          label.setBorder(javax.swing.BorderFactory.createLineBorder(new Color(0, 0, 0, 0), 1));
        }
        i++;
      }
    }
  }

  /*
   Ao digitar o último digito do candidato carregar os dados do mesmo: 
   Foto, nome, partido, etc.
   */
  private void loadDadosCandidato(String numCandidato) {
        
    lblSeuVoto.setVisible(true);
    pnlCandidatoButton.setVisible(true);
    pnlNomeCandidato.setVisible(true);    
    btnBranco.setEnabled(false);
    //
    if (numCandidato.equals("-2")) {      
      lblNomeCandidato.setText(" Voto em Branco "); 
      pnlInputNumeros.setVisible(false);
      lblNumero.setVisible(false);
    } else {
      Candidato cand;  
      //
      cand = Candidato.getCandidato(numCandidato, listaCargos.get(cargoAtual));
      if(cand.getNumeroCandidato() != 0) {
        lblNomeCandidato.setText(" Nome: ".concat(cand.getNome()));      
        lblPartido.setText(" Partido: ".concat(cand.getPartido()));    
        loadFotoCandidato(cand.getEndFotoCandidato());    
        lblTextoCandidato.setText(cand.getCargo().getNome());
        //
        if (listaCargos.get(cargoAtual).isPossuiVice()) {        
          lblVicePriSuplenteNome.setText(" Vice: ".concat(cand.getNomeVicePriSuplente()));
          loadFotoVice(cand.getEndFotoVicePriSuplente());
          lblTextoFotoVicePriSuplente.setText("Vice ".concat(cand.getCargo().getNome()));
          pnlFotoSegSuplente.setVisible(false);
        } else if (listaCargos.get(cargoAtual).isPossuiSuplentes()) {        
          lblVicePriSuplenteNome.setText(" 1º Suplente: ".concat(cand.getNomeVicePriSuplente()));
          lblTextoFotoVicePriSuplente.setText("1º Suplente");
          loadFotoVice(cand.getEndFotoVicePriSuplente());        
          lblSegSuplenteNome.setText(" 2º Suplente: ".concat(cand.getNomeSegSuplente()));      
          lblTextoFotoSegSuplente.setText("2º Suplente");
          loadFotoSegSuplente(cand.getEndFotoSegSuplente());        
        }        
      } else {
        lblNomeCandidato.setText(" Voto Nulo "); 
      }
    }
  }  
  /*
   Carrega a foto do candidato passada no endereço
   */
  private void loadFotoCandidato(String endereco) {  
    pnlFotoCandidato.setVisible(true);
    lblFotoCandidato.setSize(200, 200);
    ViewUtil.loadFoto(lblFotoCandidato, endereco);
  }

  /*
   Carrega a foto do Vice ou Primeiro Suplente passada no endereço
   */
  private void loadFotoVice(String endereco) {
    pnlFotoVicePriSuplente.setVisible(true);
    lblFotoVicePriSuplente.setSize(200, 200);
    ViewUtil.loadFoto(lblFotoVicePriSuplente, endereco);
  }

  /*
   Carrega a foto do Vice ou Primeiro Suplente passada no endereço
   */
  private void loadFotoSegSuplente(String endereco) {    
    pnlFotoSegSuplente.setVisible(true);
    lblFotoSegSuplente.setSize(200, 200);
    ViewUtil.loadFoto(lblFotoSegSuplente, endereco);
  }
  /*
  Inicialisa um novo voto ou um novo cargo
  */
  private void InicializeTelaVotacao(Cargo cargo) {
    campoAtivo = 1;
    votoBranco = false;
    lengthNumeroCargo = cargo.getQntdDigitos();

    lblSeuVoto.setVisible(false);
    pnlFotoCandidato.setVisible(false);
    pnlFotoVicePriSuplente.setVisible(false);
    pnlFotoSegSuplente.setVisible(false);
    pnlNomeCandidato.setVisible(false);
    pnlInputNumeros.setVisible(true);
    lblNumero.setVisible(true);
    setEnableButtons(true);           
    
    for (Component comp: pnlNomeCandidato.getComponents()) {      
      if ((comp instanceof JLabel)) {
        JLabel label = (JLabel) comp;        
        label.setText("");        
      }
    }
    
    pnlCandidatoButton.setVisible(false);

    for (Component comp : pnlInputNumeros.getComponents()) {
      if ((comp instanceof JLabel)) {
        JLabel label = (JLabel) comp;
        label.setVisible(true);
        label.setText("");
        label.setBorder(javax.swing.BorderFactory.createLineBorder(new Color(0, 0, 0, 255), 1));
      }
    }
    ViewUtil.stopFadeInOutBorderLabel(lblNum1);
    ViewUtil.startFadeInOutBorderLabel(lblNum1);
    configTamanhoNumeroCargo(lengthNumeroCargo);
    lblCargo.setText(cargo.getNome());
  }
  
  /*
  Retorna o numero digitado pelo eleitor
  */
  private String getNumCandidato() {
    int i = 1;
    String str = "";
    for (Component comp : pnlInputNumeros.getComponents()) {
      if ((comp instanceof JLabel)) {
        if (i <= lengthNumeroCargo) {
          JLabel label = (JLabel) comp;
          str = str.concat(label.getText());
        }
        i++;
      }
     }
    return str;
  }

  private void votar(String numCandidato) {
    
    Candidato cand;
    
    cand = Candidato.getCandidato(numCandidato, listaCargos.get(cargoAtual));
    
    if(cand.getNumeroCandidato() != 0) {
      
      Voto.inserir(new Voto(numCandidato), listaCargos.get(cargoAtual).getNome());
    } else if (numCandidato.equals("-2")){
      
      Voto.inserir(new Voto("-2"), listaCargos.get(cargoAtual).getNome());
    } else {
      
      Voto.inserir(new Voto("-1"), listaCargos.get(cargoAtual).getNome());
    }
  }
  
  private void showViewCandidato(){
    card = (CardLayout) pnlDetalheVotacao.getLayout();
    card.show(pnlDetalheVotacao, "pnlDadosCadidato");
    setEnableButtons(true);
  }
  
  private void showFimVotacao(){    
    setEnableButtons(false);
    card.show(pnlDetalheVotacao, "pnlFimVotacao");
  }
  
  private void setEnableButtons(boolean enable) {
    btnBranco.setEnabled(enable);
    btnConfirma.setEnabled(enable);
    btnCorrige.setEnabled(enable);
    setEnableTeclado(enable);
  }
  
  private void setEnableTeclado(boolean enable){
    btnNum0.setEnabled(enable);
    btnNum1.setEnabled(enable);
    btnNum2.setEnabled(enable);
    btnNum3.setEnabled(enable);
    btnNum4.setEnabled(enable);
    btnNum5.setEnabled(enable);
    btnNum6.setEnabled(enable);
    btnNum7.setEnabled(enable);
    btnNum8.setEnabled(enable);
    btnNum9.setEnabled(enable);
    
  }
  
  private boolean isEmpty() {
    
    boolean result = false;
    
    if(jTextFieldNomeEleitor.getText().isEmpty()){
      jTextFieldNomeEleitor.requestFocus();
      result = true;
    }
    if(UrnaUtil.retirarSimbolos(jFormattedTextFieldCpf.getText()).isEmpty()) {
      jFormattedTextFieldCpf.requestFocus();
      result = true;
    }
    if(UrnaUtil.retirarSimbolos(jFormattedTextFieldTitulo.getText()).isEmpty()) {
      jFormattedTextFieldTitulo.requestFocus();
      result = true;
    }
    if(UrnaUtil.retirarSimbolos(jFormattedTextFieldRg.getText()).isEmpty()) {
      jFormattedTextFieldRg.requestFocus();
      result = true;
    }
    return result;
  }
  
}
